package com.mys.maggie.redis.api.spring;

import com.mys.maggie.redis.api.bean.RedisSort;
import org.springframework.data.redis.core.Cursor;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.ScanOptions;
import org.springframework.data.redis.core.SessionCallback;
import org.springframework.data.redis.core.ZSetOperations.TypedTuple;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;

public interface MagRedisService {

    void set(String key, Object value);

    Long getExpire(String key);

    Boolean hasKey(String key);

    Boolean persistKey(String key);

    <T> Boolean set(String key, T value, long seconds);

    <T> T get(String key);

    String get(String key, long start, long end);

    <V> Boolean multiSet(Map<String, ? extends V> map);

    <V> Boolean multiSetIfAbsent(Map<String, ? extends V> m);

    <T> Map<String, T> multiGet(List<String> keys);

    Long increment(String key, long value);

    Integer append(String key, String value);

    <T> Boolean setIfAbsent(String key, T value);

    Long size(String key);

    Boolean setBit(String key, long offset, boolean value);

    Boolean getBit(String key, long offset);

    Boolean expire(String key, long expire);

    Boolean remove(String key);

    Long remove(Collection<String> keys);

    List<Object> listRange(String key, long start, long end);

    <T> Boolean listTrim(String key, long start, long end);

    <T> Long listSize(String key);

    <T> Boolean listSet(String key, long index, T value);

    <T> Long listRemove(String key, long count, Object value);

    <T> T  listIndex(String key, long index);

    <T> T  listLeftPop(String key);

    <T> T  ListLeftPop(String key, long timeout, TimeUnit unit);

    <T> T  ListRightPop(String key);

    <T> T  ListRightPop(String key, long timeout, TimeUnit unit);

    <T> T  ListRightPopAndLeftPush(String sourceKey, String destinationKey);

    <T> T  ListRightPopAndLeftPush(String sourceKey, String destinationKey, long timeout, TimeUnit unit);

    <T> Long ListLeftPushAll(String key, T... value);

    <T> Long ListLeftPushIfPresent(String key, T value);

    <T> Long ListLeftPush(String key, T pivot, T value);

    <T> Long ListLeftPush(String key, T value);

    <T> Long ListRightPush(String key, T value);

    <T> Long ListRightPush(String key, T pivot, T value);

    <T> Long ListRightPushIfPresent(String key, T value);

     <T> Long rightPushAll(String key, T... value);

    <T> boolean hashPut(String key, T hashKey, T value);

    <T, HV> boolean hashPutAll(String key, Map<String, ? extends HV> m);

    <T, HK, HV> boolean hashPutIfAbsent(String key, HK hashKey, HV value);

    <T, HK> Long hashDelete(String key, HK... hashKey);

    <T, HK> boolean hashHasKey(String key, HK hashKey);

    <T, HK> T hashGet(String key, HK hashKey);

    <T> T hashMultiGet(String key, Collection<Object> hashKeys);

    <T, HK> Long hashIncrement(String key, HK hashKey, long delta);

    <T, HK> Double hashIncrement(String key, HK hashKey, double delta);

    <T> Set<T> hashKeys(String key);

    <T> Long hashSize(String key);

    <T> List<T> hashValues(String key);

    <T> T hashEntries(String key);

    Cursor<Map.Entry<Object, Object>> hashScan(String key);

    <T> Long setAdd(String key, T... value);

    <T> Long setRemove(String key, T... value);

    <T> Object setPop(String key);

    Boolean setMove(String key, Object value, String destKey);

    <T> Long setSize(String key);

    Boolean setIsMember(String key, Object value);

    Set<Object> setIntersect(String key, String otherKey);

    Set<Object> setIntersectKeys(String key, List<String> otherKeys);

    Long setIntersectAndStore(String key, String otherKey, String destKey);

    Long setIntersectAndStore(String key, List<String> otherKeys, String destKey);

    Set<Object> setUnion(String key, String otherKeys);

    Set<Object> setUnion(String key, List<String> otherKeys);

    Long setUnionAndStore(String key, String otherKey, String destKey);

    Long setUnionAndStore(String key, List<String> otherKeys, String destKey);

    Set<Object> setDifference(String key, List<String> otherKeys);

    Set<Object> setDifference(String key, String otherKey);

    Long setDifferenceAndStore(String key, List<String> otherKeys, String destKey);

    Long setDifferenceAndStore(String key, String otherKey, String destKey);

    Set<Object> setMembers(String key);

    Object setRandomMember(String key);

    Cursor<Object> setScan(String key);

    Cursor<Object> setScan(String key, ScanOptions options);

    <T> Boolean ZSetAdd(String key, T value, double score);

    Long ZSetAdd(String key, Set<TypedTuple<Object>> tuples);

    <T> Long ZSetRemove(String key, Object... value);

    <T> Double ZSetIncrementScore(String key, T value, double delta);

    Long ZSetRank(String key, Object value);

    Long ZSetReverseRank(String key, Object value);

    Set<Object> ZSetRange(String key, long start, long end);

    Set<TypedTuple<Object>> ZSetRangeWithScores(String key, long start, long end);

    Set<Object> ZSetRangeByScore(String key, double min, double max);

    Set<TypedTuple<Object>> ZSetRangeByScoreWithScores(String key, double min, double max);

    Set<Object> ZSetRangeByScore(String key, double min, double max, long offset, long count);

    Set<TypedTuple<Object>> ZSetRangeByScoreWithScores(String key, double min, double max, long offset, long count);

    Set<Object> ZSetReverseRange(String key, long start, long end);

    Set<TypedTuple<Object>> ZSetReverseRangeWithScores(String key, long start, long end);

    Set<Object> ZSetReverseRangeByScore(String key, double min, double max);

    Set<TypedTuple<Object>> ZSetReverseRangeByScoreWithScores(String key, double min, double max);

    Set<Object> ZSetReverseRangeByScore(String key, double min, double max, long offset, long count);

    Set<TypedTuple<Object>> ZSetReverseRangeByScoreWithScores(String key, double min, double max, long offset, long count);

    Long ZSetCount(String key, double min, double max);

    Long ZSetSize(String key);

    Long ZSetzCard(String key);

    Double ZSetScore(String key, Object o);

    Long ZSetRemoveRange(String key, long start, long end);

    Long ZSetRemoveRangeByScore(String key, double min, double max);

    Long ZSetUnionAndStore(String key, String otherKey, String destKey);

    Long ZSetUnionAndStore(String key, List<String> otherKey, String destKey);

    Long ZSetIntersectAndStore(String key, String otherKey, String destKey);

    Long ZSetIntersectAndStore(String key, List<String> otherKey, String destKey);

    Cursor<TypedTuple<Object>> ZSetscan(String key);

    Map<Object, Object> ZSetScan(String key);

    boolean setSorted(String key, Object member, double score, long seconds);

    double setSortedIncrement(String key, Object member, double score, long seconds);

    double sortedScore(String key, Object member);

    boolean removeSorted(String key, Object member);

    Set<Object> rangeSorted(String key, int pageIndex, int pageSize, RedisSort redisSort);

    Set<Object> rangeSortedByScore(String key, double minScore, double maxScore, int pageIndex, int pageSize, RedisSort redisSort);

    Long sortedCount(String key, double minScore, double maxScore);

    Long sortedSize(String key);

    Long sortedRank(String key, Object member, RedisSort redisSort);

    <T> T execute(RedisCallback<T> action);

    List<Object> executePipelined(RedisCallback<?> action);

    <T> T execute(SessionCallback<T> session);

    List<Object> executePipelined(SessionCallback<?> session);

    Boolean unlink(String key);

    Long unlink(List<String> keys);

}
